import React from 'react';
import PropTypes from 'prop-types';

import LayerList from './LayerList';
import FeatureDetail from './FeatureDetail';

const SearchResult = (props) => {
    const {loading, userInfo, areaUnits, visibleFields, pageChange, pageInfo, fields, total, layerFields, featureNames, featureLocation,featureLoading, deleteFeature, saveFeature, layerDatas, featureDatas, getFeatureDetail, featureDetailShow, setFeatureDetailShow, setSearchResultShow} = props;


    // 关闭图层列表面板
    const closeLayerListPanel = () => {
        setSearchResultShow(false);
    }

    return (
        <>
            <LayerList 
                left={12}
                total={total}
                loading={loading}
                layerDatas={layerDatas}
                pageInfo={pageInfo}
                pageChange={pageChange}
                featureNames={featureNames}
                getFeatureDetail={getFeatureDetail}
                closeLayerListPanel={closeLayerListPanel}/>
            {
                featureDetailShow && 
                    <FeatureDetail 
                        userInfo={userInfo}
                        saveFeature={saveFeature}
                        layerFields={layerFields}
                        fields={fields}
                        visibleFields={visibleFields}
                        areaUnits={areaUnits}
                        featureLoading={featureLoading}
                        featureLocation={featureLocation}
                        deleteFeature={deleteFeature}
                        featureDatas={featureDatas}
                        setFeatureDetailShow={setFeatureDetailShow}/>
            }
        </>
    )
};

SearchResult.propTypes = {
    total: PropTypes.number,
    loading: PropTypes.bool,
    fields: PropTypes.object,
    pageInfo: PropTypes.object,
    userInfo: PropTypes.object,
    featureLoading: PropTypes.bool,
    layerDatas: PropTypes.array,
    visibleFields: PropTypes.array,
    featureDatas: PropTypes.object,
    featureDetailShow: PropTypes.bool,
    featureLocation: PropTypes.func,
    getFeatureDetail: PropTypes.func,
    setSearchResultShow: PropTypes.func,
    setFeatureDetailShow: PropTypes.func,
    saveFeature: PropTypes.func,
    deleteFeature: PropTypes.func,
    pageChange: PropTypes.func,
    featureNames: PropTypes.object,
    layerFields: PropTypes.object,
    areaUnits: PropTypes.object,
};

export default SearchResult;